home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: HELP!! BAMBOOZLED BEGINNER!!
- Date: 31 Jan 1996 07:46 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <31JAN199607463619@erich.triumf.ca>
- References: <Pine.OSF.3.91l.960130235948.20497A-100000@saul3.u.washington.edu>
- NNTP-Posting-Host: erich.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <Pine.OSF.3.91l.960130235948.20497A-100000@saul3.u.washington.edu>, Ramon Mariano Jr <rmariano@u.washington.edu> writes...
- >Hello everybody!
- >
- >I'm a beginning C-programmer and for the past couple of days, I've been
- >totally stuck in my program. The purpose of my program is to ask the user
- >for an integer 'i' and raise it by a power 'n'. I've been succesful in
- >computing 5 to the 6th power, 3 to the 4th power, and other small-sized
- >equations. However, when I try to raise 5 to the 7th power, I get "12589"
- >when it really should be "78125". My teacher told me that instead of using
- >plain 'int', I should use 'long int'. I tried that, but it's still not
- >working. If anyone can help me out here, I'd GREATLY appreciate it! I've
- >included my code below... (by the way, I'm not allowed to use the <math.h>
- >library)
-
- If you are working in MS-DOS, an int on most compilers is 16 bits, which gives
- a range of -32768 to 32767. A long int is 32 bits, which will have a range of
- about +/- 2 billion.
-
- To print a long int, you need to use "%ld" instead of "%d" in printf().
-
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
-
-
-
-
-
-
-
-